<template>
  <el-popover
    ref="popover"
    placement="left"
    width="300"
    @show="setData"
  >
    <el-form v-model="auditForm">
      <el-form-item>
        <el-row :gutter="10">
          <el-col :span="18">
            <el-radio-group v-model="auditForm.auditStatus">
              <el-radio :label="1">通过</el-radio>
              <el-radio :label="2">不通过</el-radio>
            </el-radio-group>
          </el-col>
          <el-col :span="6">
            <el-button size="mini" type="primary" :loading="loading" round @click="submit">保 存</el-button>
          </el-col>
        </el-row>
      </el-form-item>
      <el-form-item>
        <el-input
          v-model="auditForm.auditOpinion"
          type="textarea"
          autosize
          placeholder="请输入审核意见"
        />
      </el-form-item>
    </el-form>
    <el-button slot="reference" size="small" type="primary" icon="el-icon-edit" circle />
  </el-popover>
</template>

<script>
import { updateDamageNotice } from '@/api/dailyInspection'

export default {
  name: 'DamageNoticeAudit',
  props: {
    data: {
      type: Object,
      default() {
        return {}
      }
    }
  },
  data() {
    return {
      auditForm: {
        damageNoticeID: '',
        auditStatus: 1,
        auditOpinion: ''
      },
      loading: false
    }
  },
  methods: {
    submit() {
      this.loading = true
      updateDamageNotice(this.auditForm).then(() => {
        this.$emit('submitSuccess')
        this.$message.success('保存成功')
        this.loading = false
      })
    },
    setData() {
      this.auditForm = this.data
    }
  }
}
</script>

<style scoped>

</style>
